//lambda使用
fun main() {
    //函数的参数是另外一个函数
    var getDiscountWords =  {goodsName:String, hour:Int ->
        var currentYear = 2027
        "${currentYear}年，双11${goodsName}促销倒计时：${hour}小时"
    }
    showOnBoard("卫生纸",getDiscountWords)
    //简略写法

    val total = "mississippi".count()
    var total01 = "mississippi".count({letter ->
        letter == 's'
    })
    //简写，省略传参和()
    val total02 = "mississippi".count{it == 's'}
    println(total)
    println(total01)
    println(total02)
}

private fun showOnBoard(goodsName:String, getDiscountWords:(String,Int)->String) {
    var hour = (1..24).shuffled().last()
    println(getDiscountWords(goodsName,hour))
}